﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace JESAI.DynamicWebApi.Configurations
{
    public class DynamicWebApiConfiguration: IDynamicWebApiConfiguration
    {

        public List<Type> FormBodyBindingIgnoredTypes { get; }
        public DynamicWebApiControllerAssemblySettingList dynamicWebApiControllerAssemblySettings { get; }

        public DynamicWebApiConfiguration()
        {
            FormBodyBindingIgnoredTypes = new List<Type>();
            dynamicWebApiControllerAssemblySettings = new DynamicWebApiControllerAssemblySettingList();
        }

        /// <summary>
        /// 为动态WebApi根据AppService创建控制器
        /// </summary>
        /// <param name="assembly"></param>
        /// <param name="moduleName"></param>
        /// <param name="useConventionalHttpVerbs"></param>
        /// <returns></returns>
        public IDynamicWebApiControllerAssemblySettingBuilder CreateControllersForAppServices(
           Assembly assembly,
           string moduleName = AppConsts.DefaultServiceModuleName,
           bool useConventionalHttpVerbs = true)
        {
            var setting = new DynamicWebApiControllerAssemblySetting(moduleName, assembly, useConventionalHttpVerbs);
            dynamicWebApiControllerAssemblySettings.Add(setting);
            return new DynamicWebApiControllerAssemblySettingBuilder(setting);
        }
    }
}
